package trece;

import java.awt.event.*;

public class ControlDemoCombo implements ActionListener {
	WindowDemoCombo frameDemoCombo;

	public ControlDemoCombo(WindowDemoCombo objeto) {
		frameDemoCombo = objeto;
	}

	public void actionPerformed(ActionEvent evento) {
		if (evento.getSource() == frameDemoCombo.jComboBox1)// pregunta si el
															// evento viene del
															// primer combo
		{/* pregunta si viene del primer elemnto */
			if (frameDemoCombo.jComboBox1.getSelectedIndex() == 0) {
				frameDemoCombo.jComboBox2.removeAllItems();
				frameDemoCombo.jComboBox2.setEnabled(false);
			}
			/* pregunta si viene del segundo elemnto */
			if (frameDemoCombo.jComboBox1.getSelectedIndex() == 1) {
				frameDemoCombo.jComboBox2.removeAllItems();
				for (int i = 0; i < frameDemoCombo.regionArgentina.length; i++)
					frameDemoCombo.jComboBox2
							.addItem(frameDemoCombo.regionArgentina[i]);
				frameDemoCombo.jComboBox2.setEnabled(true);
			}
			/* pregunta si viene del tercer elemnto */
			if (frameDemoCombo.jComboBox1.getSelectedIndex() == 2) {
				frameDemoCombo.jComboBox2.removeAllItems();
				for (int i = 0; i < frameDemoCombo.regionColombia.length; i++)
					frameDemoCombo.jComboBox2
							.addItem(frameDemoCombo.regionColombia[i]);
				frameDemoCombo.jComboBox2.setEnabled(true);
			}
			/* pregunta si viene del cuarto elemnto */
			if (frameDemoCombo.jComboBox1.getSelectedIndex() == 3) {
				frameDemoCombo.jComboBox2.removeAllItems();
				for (int i = 0; i < frameDemoCombo.regionPeru.length; i++)
					frameDemoCombo.jComboBox2
							.addItem(frameDemoCombo.regionPeru[i]);
				frameDemoCombo.jComboBox2.setEnabled(true);
			}
		}
	}
}